import {
  Controller,
  Req,
  Get,
  Query,
  Headers,
  Param,
  Post,
  Body,
} from '@nestjs/common';
import { Request } from 'express';
import { CreatePostDto } from './post.dto';
@Controller('posts')
export class PostsController {
  @Get()
  index(@Req() request: Request, @Query() query, @Headers() headers) {
    return {
      hostname: request.hostname,
      ip: request.ip,
      method: request.method,
      query: query,
      headers: headers,
    };
  }
  @Get(':id')
  show(@Param() param) {
    return {
      title: `Post ${param.id}`,
    };
  }

  @Post()
  store(@Body() post: CreatePostDto) {
    return post.title;
  }
}
